import { createRouter, createWebHashHistory } from 'vue-router'
const Index = ()=>import("../views/index/Index.vue");
const Index2 = ()=>import("../views/index/Index2.vue");
const Profile = ()=> import("../views/profile/Profile.vue");
const Sign = ()=>import("../views/sign/Sign.vue");
const Score = ()=> import("../views/score/Score.vue");
const MyMatch = ()=> import("../views/myMatch/myMatch.vue"); 
const EntryDetail = ()=> import("../views/entryDetails/entryDetails.vue"); 
const FillInfo =  ()=>import("../views/fillInfo/FillInfo.vue"); 
const MatchRules =  ()=>import("../views/matchRules/MatchRules.vue"); 
const Level3up =  ()=>import("../views/matchRules/Level3up.vue"); 
const UploadInfo =  ()=>import("../views/matchRules/UploadInfo.vue"); 
const ActionDetail = ()=> import("../views/actionDetail/ActionDetail.vue"); 
const ScoreInquiry = ()=> import("../views/scoreInquiry/ScoreInquiry.vue") 
const MyCertificate = ()=> import("../views/myCertificate/myCertificate.vue")
const ManEntryDetail = ()=> import("../views/entryDetails/manEntryDetails.vue")
const WomanEntryDetail = ()=> import("../views/entryDetails/womanEntryDetails.vue")
const Address = ()=> import("../views/address/address.vue")
const myVideo = ()=> import("../views/myVideo/MyVideo.vue")
const routes = [
  {
    path: '/',
    redirect:"/index"
  },
  {
    path: '/index',
    name: 'index',
    component: Index2
    // component: Index
  },
  {
    path: '/sign',
    name: 'sign', 
    component: Sign
  },
  {
    path: '/score',
    name: 'score',
    component: Score
  },
  {
    path: '/profile',
    name: 'profile',
    component:Profile
  },
  {
    path:'/mymatch',
    name:'MyMatch',
    component:MyMatch
  },
  {
    path:'/entrydetail',
    name:'EntryDetail',
    component:EntryDetail
  },
  {
    path:'/scoreinquiry',
    name:'ScoreInquiry',
    component:ScoreInquiry
  }, 
    {
    path:'/fillinfo',
    name:'fillinfo',
    component:FillInfo,
    // meta:{
    //   keepAlive:true
    // }
  },
  {
    path:'/matchRules',
    name:'matchRules',
    component:MatchRules,
    meta:{
      // keepAlive:true
    }
  },
  {
    path:'/Level3up',
    name:'Level3up',
    component:Level3up,
  },
  {
    path:'/actionDetail',
    name:'actionDetail',
    component:ActionDetail,
  },
  {
    path:'/mycertificate',
    name:'MyCertificate',
    component:MyCertificate
  },
  {
    path:'/manentrydetail',
    name:'ManEntryDetail',
    component:ManEntryDetail
  },
  {
    path:'/womanentrydetail',
    name:'WomanEntryDetail',
    component:WomanEntryDetail
  },
  {
    path:'/address',
    name:'Address',
    component:Address
  },
  {
    path:'/myvideo',
    name:'Video',
    component:myVideo
  },
  {
    path:'/uploadinfo',
    name:'UploadInfo',
    component:UploadInfo
  }
  
]

const router = createRouter({
  history: createWebHashHistory(),
  scrollBehavior (to, from, savedPosition) {
    // console.log(savedPosition);
    // if(to.path=== "/actionDetail" && from.path=== "/fillinfo"){
    //   console.log(23456);
    //   return {x: 0, y: 0}
    // }
    // else 
    if (savedPosition) { //如果savedPosition存在，滚动条会自动跳到记录的值的地方
      return savedPosition
    } else {
      return {left: 0, right: 0}//savedPosition也是一个记录x轴和y轴位置的对象
    }
  },
  routes
})

export default router
